<?php 
use_stylesheet('list.css');
use_helper('toolsbar');
slot('Toolsbar');
   echo setToolbar('index','subcontract');
end_slot();

slot('PageTitle',"Subcontract");
slot('Title',"Subcontract Overview");

        
?>
<table id=lista>
  <thead>
    <tr>
      <th <?php if ($sf_user->getOrderField()=='plant') echo 'class=order'?>><a href="<?php echo url_for('subcontract')."?orderBy=plant"?>">Plant</a></th>
      <th <?php if ($sf_user->getOrderField()=='type') echo 'class=order'?>><a href="<?php echo url_for('subcontract')."?orderBy=type"?>">Type</a></th>
      <th <?php if ($sf_user->getOrderField()=='supplier') echo 'class=order'?>><a href="<?php echo url_for('subcontract')."?orderBy=supplier"?>">Supplier</a></th>
      <th <?php if ($sf_user->getOrderField()=='fee') echo 'class=order'?>><a href="<?php echo url_for('subcontract')."?orderBy=fee"?>">Fee</a></th>
      <th <?php if ($sf_user->getOrderField()=='start') echo 'class=order'?>><a href="<?php echo url_for('subcontract')."?orderBy=start"?>">Start</a></th>
      <th <?php if ($sf_user->getOrderField()=='end') echo 'class=order'?>><a href="<?php echo url_for('subcontract')."?orderBy=end"?>">End</a></th>
      <th <?php if ($sf_user->getOrderField()=='note') echo 'class=order'?>><a href="<?php echo url_for('subcontract')."?orderBy=note"?>">Note</a></th>
      <th <?php if ($sf_user->getOrderField()=='payments') echo 'class=order'?>><a href="<?php echo url_for('subcontract')."?orderBy=payments"?>">Payments</a></th>
    </tr>
  </thead>
  <tbody>
      
    <?php 
    $prevPlant="";
    $odd="odd";
    foreach ($subcontracts as $key=>$subcontract): 
        if ($prevPlant!=$subcontract->getPlant()){
            $odd = ($odd=="odd")? 'even' : 'odd';
            $prevPlant=$subcontract->getPlant();
         }?>
 
     <tr class="<?php echo $odd ?>">
      
      <td><a href="<?php echo url_for('subcontract_show',$subcontract) ?>"><?php echo $subcontract->getPlant() ?></a></td>
      <td><?php echo $subcontract->getType() ?></td>     
      <td><a href="<?php echo url_for('supplier_show',$subcontract->getSupplier()) ?>"><?php echo $subcontract->getSupplier() ?></td>
      <td class="nowrap"><?php echo is_null($subcontract->getFee())?"-":$subcontract->getFee()." €" ?></td>
      <td class="nowrap"><?php echo $subcontract->getStart() ?></td>
      <td class="nowrap"><?php echo $subcontract->getEnd() ?></td>
      <td><?php $note=  strlen($subcontract->getNote())>15?substr($subcontract->getNote(), 0, 15)." ..":$subcontract->getNote(); echo $note ?></td>
      <td><?php echo $subcontract->getPayments() ?></td>
    </tr>
    <?php endforeach; ?>
  </tbody>
</table>

